﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Saker.Kernel.BLL;

namespace Saker.Web.Boss.Sys.User
{
    public partial class List : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        public void BindData()
        {
            int recordcount = 0, pagecount = 0;
            DataTable dt = new SysUserBLL().GetPagingRecord(UserPager.CurrentPageIndex - 1, ref recordcount, UserPager.PageSize, ref pagecount, "");
            RepUserList.DataSource = dt;
            RepUserList.DataBind();
            UserPager.RecordCount = recordcount;
        }

        protected void RepUserList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "EditUser")
            {
                Response.Redirect("Add.aspx?CMD=Edit&UserID=" + e.CommandArgument.ToString());
            }
            if (e.CommandName == "DeleteUser")
            {
                if (new SysUserBLL().DeleteByUserID(int.Parse(e.CommandArgument.ToString())) > 0)
                {
                    BindData();
                    ScriptManager.RegisterStartupScript((Page)this, this.Page.GetType(), "alert", "$(function () { top.jBox.tip('用户删除成功！', 'success'); });", true);
                }
            }
        }
    }
}